/* 数据层 */
const  mysql=require('mysql2')

const pool=mysql.createPool({
    host:'127.0.0.1',
    port:3306,
    user:'root',
    password:'123456',
    database:'bookshop',
    multipleStatements:true
})

//封装
module.exports.dbsql=(sql,params,callback)=>{
    pool.getConnection((err,conn)=>{
        if(err){
            return callback(err,null)
        }
        conn.query(sql,params,(err,results)=>{
            if(err){
                return callback(err,null)
            }
            callback(null,results)
        })
        conn.release()
    })
}